<script setup lang="ts">
import { onLaunch, onShow, onHide } from "@dcloudio/uni-app"
import { useUserStore } from './stores'
import { initWebSocket, setUrl } from "./utils/ws"

// 用户存储
const userStore = useUserStore()

onLaunch(() => {
  console.log("App Launch");
});
onShow(() => {
  console.log("App Show");
  if (userStore.profile.user) {
    let wsUrl = ''
    const params = userStore.profile.user.uid + '&username=' + userStore.profile.user.username + '&token=' + userStore.profile.token
    if (import.meta.env.DEV) {
      wsUrl = 'ws://127.0.0.1:7272?uid=' + params
    } else {
      wsUrl = 'wss://ws.itrident.cn?uid=' + params
    }
    setUrl(wsUrl)
    initWebSocket()
  }
});
onHide(() => {
  console.log("App Hide")
});
</script>
<style lang="scss">
// 字体图标
@import '@/styles/fonts.scss';

page {
  background-color: #f1fbf9;
}

view,
navigator,
input,
scroll-view {
  box-sizing: border-box;
}

button::after {
  border: none;
}

swiper,
scroll-view {
  flex: 1;
  height: 100%;
  overflow: hidden;
}

image {
  width: 100%;
  height: 100%;
  vertical-align: middle;
}

.ellipsis-1 {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
}

.ellipsis-2 {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

::-webkit-scrollbar {
  display: none;
}
</style>
